﻿Imports System.Data.OracleClient
Imports ccapps.Web.page


Namespace persistent


    Public Class NetworkRequest
        Private Shared ConnStr As String = GlobalVar.OraConnStr

        Private Shared dbPackageName As String = "EU_BILL.NetworkRequestViewDelete."

       


        Public Shared Function GetCustomerInfoFromMSISDN(ByVal pin_msisdn As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetCustomerInfoFromMSISDN")
            'pin_msisdn = "90" + pin_msisdn
            command.Parameters.Add("pin_MSISDN", OracleType.VarChar).Value = pin_msisdn
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA 
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New NetworkRequestViewDelete()
            persistent.myDBConn.ORAScalar_LOG(Query, "null", "null", "null", pin_msisdn, "Select(GetCustomerInfoFromMSISDN)", "NetworkRequest", gen.Session("user"))

            Return ExecuteDataTable(command)

        End Function

        Public Shared Function GetCustomerInfoFromCOID(ByVal pin_co_id As Integer) As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetCustomerInfoFromCOID")
            command.Parameters.Add("pin_coid", OracleType.Int32).Value = pin_co_id
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function

        Public Shared Function DisplayPendingRequests(ByVal pin_customer_id As Integer, ByVal pin_co_id As Integer) As DataTable

            Dim command As New OracleCommand(dbPackageName & "DisplayPendingRequests")
            command.Parameters.Add("pin_customer_id", OracleType.Int32).Value = pin_customer_id
            command.Parameters.Add("pin_co_id", OracleType.Int32).Value = pin_co_id
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA 
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New NetworkRequestViewDelete()
            persistent.myDBConn.ORAScalar_LOG(Query, "null", pin_customer_id, "null", "null", "Select(DisplayPendingRequests)", "NetworkRequest", gen.Session("user"))
            Return ExecuteDataTable(command)

        End Function

        Public Shared Function DisplayFailedRequests(ByVal pin_customer_id As Integer, ByVal pin_co_id As Integer) As DataTable

            Dim command As New OracleCommand(dbPackageName & "DisplayFailedRequests")
            command.Parameters.Add("pin_customer_id", OracleType.Int32).Value = pin_customer_id
            command.Parameters.Add("pin_co_id", OracleType.Int32).Value = pin_co_id
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA 
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New NetworkRequestViewDelete()
            persistent.myDBConn.ORAScalar_LOG(Query, "null", pin_customer_id, "null", "null", "Select(DisplayFailedRequests)", "NetworkRequest", gen.Session("user"))

            Return ExecuteDataTable(command)

        End Function


        Public Shared Function NetworkRequestResend(ByVal pin_request As String) As DataTable
            Dim request As Integer = Convert.ToInt32(pin_request)
            Dim command As New OracleCommand(dbPackageName & "NetworkRequestResend")
            command.Parameters.Add("pin_request", OracleType.Int32).Value = request
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function

        Public Shared Function NetworkRequestCancel(ByVal pin_request As String) As DataTable
            Dim request As Integer = Convert.ToInt32(pin_request)
            Dim command As New OracleCommand(dbPackageName & "NetworkRequestCancel")
            command.Parameters.Add("pin_request", OracleType.Int32).Value = request
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function


        Public Shared Function ExecuteNonQuery(ByVal command As OracleCommand, ByRef MESSAGE As String)
            Dim connection As New OracleConnection(ConnStr)
            command.Connection = connection
            command.CommandType = CommandType.StoredProcedure

            Try
                connection.Open()
                command.ExecuteNonQuery()
            Catch ex As Exception
                MESSAGE = ex.Message.ToString
            Finally
                connection.Close()
            End Try
        End Function
        Public Shared Function ExecuteDataTable(ByVal command As OracleCommand, Optional ByVal directSql As Boolean = 0) As DataTable
            Dim connection As New OracleConnection(ConnStr)
            Dim dataAdapter As New OracleDataAdapter(command)
            Dim dataTable As New DataTable
            Dim dataSet As New DataSet

            command.Connection = connection

            If Not (directSql) Then
                command.CommandType = CommandType.StoredProcedure
            End If

            Try
                connection.Open()
                dataAdapter.Fill(dataSet)
                dataTable = dataSet.Tables(0)
            Catch ex As Exception
            Finally
                connection.Close()
                dataSet.Dispose()
            End Try

            Return dataTable
        End Function




    End Class
End Namespace



